package com.examp.mizugiapps;

import android.net.ConnectivityManager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		final EditText et = (EditText) findViewById(R.id.editText1);
		
		Button b = (Button) findViewById(R.id.button1);
		b.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(MainActivity.this, second.class);
				intent.putExtra("Msg1", et.getText().toString());
				startActivity(intent);
			}
		});		
		
		Button c = (Button) findViewById(R.id.button2);
		c.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(new Intent(MainActivity.this, Third.class));
			}
		});
		
		// Checking wifi turn on or off??
		ConnectivityManager conn = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
		TextView tvwifi = (TextView) findViewById(R.id.textView2);
		TextView tvthreeG = (TextView) findViewById(R.id.textView3);
		boolean wifi = conn.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
		boolean threeG = conn.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();
		if (wifi) {
			tvwifi.setText("This wifi is ON!");
		} else {
			tvwifi.setText("This wifi is OFF!");
		}
		
		if (threeG) {
			tvthreeG.setText("This 3G is ON!");
		} else {
			tvthreeG.setText("This 3G is OFF!");
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
